/*
 * Copyright (c) 2023 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
#ifndef DEV_NCSI_SOCKET_H
#define DEV_NCSI_SOCKET_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

/* Select Package Command (0x01) */
#define SELECT_PACKAGE_REQ_LEN     4
#define SELECT_PACKAGE_RSP_LEN     4
#define SELECT_PACKAGE_REQ_PAD_LEN 22
#define SELECT_PACKAGE_RSP_PAD_LEN 22
#define OEM_PACKAGE_REQ_LEN        7
#define OEM_PACKAGE_RSP_LEN        10
#define OEM_PACKAGE_REQ_PAD_LEN    22
#define OEM_PACKAGE_RSP_PAD_LEN    22

#ifndef NCSI_MAC_LEN
#define NCSI_MAC_LEN 6
#endif

#ifndef NCSI_ETHER_MIN_LEN
#define NCSI_ETHER_MIN_LEN 290 // 46-1500 bytes:Data(NC-SI Control Packet)
#endif

#pragma pack(1)

/* The Management Controller shall format the 14-byte Ethernet frame header so that when it is
received, it shall be formatted in the big-endian byte order . Bits
___________________________________________________________
| Bytes |  31..24   |   23..16   |   15..08   |  07..00    |
|_______|___________|____________|____________|____________|
|00..03 | DA5= 0xFF | DA4= 0xFF  | DA3= 0xFF  | DA2= 0xFF  |
|_______|___________|_________________________|____________|
|04..07 | DA1= 0xFF | DA0= 0xFF  |    SA5     |   SA4      |
|_______|___________|_________________________|____________|
|08..11 |    SA3    |   SA2      |    SA1     |   SA0      |
|_______|___________|_________________________|____________|
|12..13 | EtherType = 0x88F8 (DMTF NC-SI)                  |
|_______|__________________________________________________| */
typedef struct tg_ethernet_header {
    uint8_t  des_address[NCSI_MAC_LEN];
    uint8_t  src_address[NCSI_MAC_LEN];
    uint16_t ether_type;
} ethernet_header, *p_ethernet_header;

/* he 16-byte control packet header is used in command, response, and AEN packets, and contains data
1413 values intended to allow the packet to be identified, validated, and processed. The packet
header is in  1414 big-endian byte order.

Bytes      31..24                  23..16             15..08        07..00
00..03     MC ID                Header Revision      Reserved         IID
04..07  Control Packet Type        Ch. ID            Reserved    Payload Length
08..11  Reserved
12..15  Reserved */
typedef struct tg_ctl_packet_header {
    uint8_t mc_id; // Management Controller ID
    uint8_t header_revision;
    uint8_t reserved;
    uint8_t iid;         // Instance ID
    uint8_t packet_type; // Control Packet Type
#ifdef BD_BIG_ENDIAN
    uint8_t package_id : 3;
    uint8_t channel_id : 5;
#else
    uint8_t channel_id : 5;
    uint8_t package_id : 3;
#endif
#ifdef BD_BIG_ENDIAN
    uint8_t reserved1      : 4;
    uint8_t payload_len_hi : 4;
#else
    uint8_t payload_len_hi : 4;
    uint8_t reserved1      : 4;
#endif
    uint8_t payload_len_lo;
    int32_t reserved2;
    int32_t reserved3;
} ctl_packet_header, *p_ctl_packet_header;

#define ETHER_HEADER_LEN  14
#define PACKET_HEADER_LEN 16

/* AEN packets
Bytes           31..24                    23..16              15..08                07..00
00..03        MC ID = 0x0                   0x01             Reserved              IID = 0x0
04..07  Control Packet Type = 0xFF     Originating Ch.ID      Reserved         Payload Length = 0x4
08..11        Reserved
12..15        Reserved
16..19        Reserved                                                              AEN Type
20..23        OPTIONAL AEN Data
24..27        Checksum */
typedef struct tg_aen_packet {
    ethernet_header   frame_head;
    ctl_packet_header packet_head;
    uint8_t           reserved[3];
    uint8_t           aen_type;
    int32_t           optional_aen_data;
    int32_t           checksum;
} aen_packet, *p_aen_packet;

#ifndef NCSI_ETH_NAME_LEN
#define NCSI_ETH_NAME_LEN 16
#endif

typedef struct tg_common_packet_except_name {
    ethernet_header   frame_head;
    ctl_packet_header packet_head;
    uint8_t           payload[NCSI_ETHER_MIN_LEN * 4 - ETHER_HEADER_LEN - PACKET_HEADER_LEN];
} common_packet_except_name, *p_common_packet_except_name;

typedef struct tg_select_package {
    uint8_t reserved1[3];
#ifdef BD_BIG_ENDIAN
    uint8_t reserved2      : 7;
    uint8_t hd_arbitration : 1;
#else
    uint8_t hd_arbitration : 1;
    uint8_t reserved2      : 7;
#endif
    uint32_t check_sum;
    uint8_t  pad_data[SELECT_PACKAGE_REQ_PAD_LEN];
    uint32_t FCS;
} select_package, *p_select_package;

/* Select Package Response (0x81) */
typedef struct tg_select_package_rsp {
    uint16_t rsp_code;
    uint16_t reason_code;
    uint32_t check_sum;
    uint8_t  pad_data[SELECT_PACKAGE_RSP_PAD_LEN];
    uint32_t FCS;
} select_package_rsp, *p_select_package_rsp;

#define CLEAR_INITIAL_REQ_PAD_LEN 26
#define CLEAR_INITIAL_RSP_PAD_LEN 22
typedef struct tg_clear_initial_state {
    uint32_t check_sum;
    uint8_t  pad_data[CLEAR_INITIAL_REQ_PAD_LEN];
    uint32_t FCS;
} clear_initial_state, *p_clear_initial_state;
/* Clear Initial State Response (0x80)  */
typedef struct tg_clear_initial_state_rsp {
    uint16_t rsp_code;
    uint16_t reason_code;
    uint32_t check_sum;
    uint8_t  pad_data[CLEAR_INITIAL_RSP_PAD_LEN];
    uint32_t FCS;
} clear_initial_state_rsp, *p_clear_initial_state_rsp;

typedef struct tg_oem_package {
    uint32_t manufacturer_id;
    uint8_t  cmd_number;
    uint8_t  cmd_opt_data[3];
    uint8_t  pad_data[OEM_PACKAGE_REQ_PAD_LEN];
    uint32_t FCS;
} oem_package, *p_oem_package;

typedef struct tg_oem_package_rsp {
    uint16_t rsp_code;
    uint16_t reason_code;
    uint32_t manufacturer_id;
    uint32_t pad_data[OEM_PACKAGE_RSP_PAD_LEN];
    uint32_t FCS;
} oem_package_rsp, *p_oem_package_rsp;

#define LLDP_OVER_NCSI_RESERVED_BYTES 3
typedef struct tag_get_lldp_over_ncsi_rsp {
    uint8_t  status;
    uint8_t  reserved[LLDP_OVER_NCSI_RESERVED_BYTES];
    uint32_t check_sum;
} get_lldp_over_ncsi_rsp, *p_get_lldp_over_ncsi_rsp;

#define FACTORY_MAC_RESERVED_BYTES 3
#define MAX_PCIE_MAC_NUM           8 /* 最多8个MAC */
#define MAC_ADDR_BYTES_NUM         6
typedef struct tag_get_factory_default_mac_rsp {
    uint8_t  mac_count;
    uint8_t  reserved[FACTORY_MAC_RESERVED_BYTES];
    uint8_t  mac_addr[MAX_PCIE_MAC_NUM][MAC_ADDR_BYTES_NUM];
    uint32_t check_sum;
} get_factory_default_mac_rsp, *p_get_factory_default_mac_rsp;

/* Get Version ID Command (0x15) */
#define GET_VERSION_ID_REQ_LEN     0
#define GET_VERSION_ID_RSP_LEN     40
#define GET_VERSION_ID_REQ_PAD_LEN 26

typedef struct tg_get_version_id {
    uint32_t check_sum;
    uint8_t  pad_data[GET_VERSION_ID_REQ_PAD_LEN];
    uint32_t FCS;
} get_version_id, *p_get_version_id;

/* Get Version ID Response (0x95)   */
typedef struct tg_get_version_id_rsp {
    uint16_t rsp_code;
    uint16_t reason_code;
    uint8_t  major_ver;
    uint8_t  minor_ver;
    uint8_t  update_ver;
    uint8_t  alpha1;
    uint8_t  reserved[3];
    uint8_t  alpha2;
    uint8_t  name_string[12]; /* 大字序，收到的第一个字节为名字的第一个字节 */
    uint8_t  firmware_ver[4];
    uint16_t pci_did;
    uint16_t pci_vid;
    uint16_t pci_ssid;
    uint16_t pci_svid;
    uint32_t manufacturer_id; /* This field is unused, the value shall be set to 0xFFFFFFFF */
    uint32_t check_sum;
    uint32_t FCS;
} get_version_id_rsp, *p_get_version_id_rsp;

#define NCSI_MAC_LEN                6
#define SET_MAC_ADDRESS_REQ_PAD_LEN 18
typedef struct tg_set_mac_address {
    uint8_t mac_filter[NCSI_MAC_LEN];
    uint8_t mac_number;
#ifdef BD_BIG_ENDIAN
    uint8_t address_type : 3;
    uint8_t reserved     : 4;
    uint8_t mac_enable   : 1;
#else
    uint8_t mac_enable   : 1;
    uint8_t reserved     : 4;
    uint8_t address_type : 3;
#endif
    uint32_t check_sum;
    uint8_t  pad_data[SET_MAC_ADDRESS_REQ_PAD_LEN];
    uint32_t FCS;
} set_mac_address, *p_set_mac_address;

/* Set Vlan Filter (0x0B)  */
#define SET_VLAN_FILTER_REQ_PAD_LEN 18
typedef struct tg_set_vlan_filter {
    uint8_t reserved1[2];
#ifdef BD_BIG_ENDIAN
    uint8_t user_priority : 4;
    uint8_t vlan_id_hi    : 4;
#else
    uint8_t vlan_id_hi    : 4;
    uint8_t user_priority : 4;
#endif
    uint8_t vlan_id_low;
    uint8_t reserved2[2];
    uint8_t filter;
#ifdef BD_BIG_ENDIAN
    uint8_t reserved3 : 7;
    uint8_t enable    : 1;
#else
    uint8_t enable    : 1;
    uint8_t reserved3 : 7;
#endif

    uint32_t check_sum;
    uint8_t  pad_data[SET_VLAN_FILTER_REQ_PAD_LEN];
    uint32_t FCS;
} set_vlan_filter, *p_set_vlan_filter;

typedef struct tg_boradcast_filter {
    uint8_t reserved1[3];
#ifdef BD_BIG_ENDIAN
    uint32_t reserved2          : 4;
    uint32_t netbios_packet     : 1; // This field is optional.
    uint32_t dhcp_server_packet : 1; // This field is optional.
    uint32_t dhcp_client_packet : 1; // This field is optional.
    uint32_t arp_packet         : 1; // This field is mandatory.
#else
    uint32_t arp_packet         : 1;
    uint32_t dhcp_client_packet : 1;
    uint32_t dhcp_server_packet : 1;
    uint32_t netbios_packet     : 1;
    uint32_t reserved2          : 4;
#endif
} boradcast_filter, *p_boradcast_filter;

#define ENABLE_BROADFILTER_REQ_PAD_LEN 22
typedef struct tg_enable_broadcast {
    boradcast_filter brd_filter;
    uint32_t         check_sum;
    uint8_t          pad_data[ENABLE_BROADFILTER_REQ_PAD_LEN];
    uint32_t         FCS;
} enable_broadcast, *p_enable_broadcast;

/* Enable Broadcast Filter Response (0x90)   */
#define ENABLE_BROADFILTER_RSP_PAD_LEN 22
typedef struct tg_enable_broadcast_rsp {
    uint16_t rsp_code;
    uint16_t reason_code;
    uint32_t check_sum;
    uint8_t  pad_data[ENABLE_BROADFILTER_RSP_PAD_LEN];
    uint32_t FCS;
} enable_broadcast_rsp, *p_enable_broadcast_rsp;

/* Enable Global Multicast Filter Command (0x12) */
#define ENABLE_MULTICAST_REQ_LEN     4
#define ENABLE_MULTICAST_RSP_LEN     4
#define ENABLE_MULTICAST_REQ_PAD_LEN 22
#define ENABLE_MULTICAST_RSP_PAD_LEN 22

typedef struct tg_enable_multicast {
    uint32_t multicast_filter;
    uint32_t check_sum;
    uint8_t  pad_data[ENABLE_MULTICAST_REQ_PAD_LEN];
    uint32_t FCS;
} enable_multicast, *p_enable_multicast;
/* Disable Global Multicast Filter Response (0x92) */
typedef struct tg_enable_multicast_rsp {
    uint16_t rsp_code;
    uint16_t reason_code;
    uint32_t check_sum;
    uint8_t  pad_data[ENABLE_MULTICAST_RSP_PAD_LEN];
    uint32_t FCS;
} enable_multicast_rsp, *p_enable_multicast_rsp;

/* Disable Global Multicast Filter Command (0x13) */
#define DISABLE_MULTICAST_REQ_LEN     0
#define DISABLE_MULTICAST_RSP_LEN     4
#define DISABLE_MULTICAST_REQ_PAD_LEN 26
#define DISABLE_MULTICAST_RSP_PAD_LEN 22

typedef struct tg_disable_multicast {
    uint32_t check_sum;
    uint8_t  pad_data[DISABLE_MULTICAST_REQ_PAD_LEN];
    uint32_t FCS;
} disable_multicast, *p_disable_multicast;
/* Disable Global Multicast Filter Response (0x93) */
typedef struct tg_disable_multicast_rsp {
    uint16_t rsp_code;
    uint16_t reason_code;
    uint32_t check_sum;
    uint8_t  pad_data[DISABLE_MULTICAST_RSP_PAD_LEN];
    uint32_t FCS;
} disable_multicast_rsp, *p_disable_multicast_rsp;

/* AEN Enable Command (0x08)  */
#define AEN_ENABLE_REQ_LEN     8
#define AEN_ENABLE_RSP_LEN     4
#define AEN_ENABLE_REQ_PAD_LEN 18
#define AEN_ENABLE_RSP_PAD_LEN 22

typedef struct tg_enable_aen {
    uint8_t  reserved1[3];
    uint8_t  mc_id;
    uint16_t oem_ctl;
    uint8_t  reserved;
#ifdef BD_BIG_ENDIAN
    uint8_t reserved2 : 5;
    /* 1b  = Enable Host NC Driver Status Change AEN  0=disable */
    uint8_t drv_change : 1;
    /* 1b  = Enable Host NC Driver Status Change AEN 0=disable */
    uint8_t config_req : 1;
    /* 1b  = Enable Link Status Change AEN  0=disable */
    uint8_t link_status : 1;
#else
    uint8_t link_status : 1;
    uint8_t config_req  : 1;
    uint8_t drv_change  : 1;
    uint8_t reserved2   : 5;
#endif
    uint32_t check_sum;
    uint8_t  pad_data[AEN_ENABLE_REQ_PAD_LEN];
    uint32_t FCS;
} enable_aen, *p_enable_aen;
/* AEN Enable Response (0x88)  */
typedef struct tg_enable_aen_rsp {
    uint16_t rsp_code;
    uint16_t reason_code;
    uint32_t check_sum;
    uint8_t  pad_data[AEN_ENABLE_RSP_PAD_LEN];
    uint32_t FCS;
} enable_aen_rsp, *p_enable_aen_rsp;

typedef struct tg_capbility_define {
#ifdef BD_BIG_ENDIAN
    uint32_t reserved      : 27;
    uint32_t multicast_sup : 1;     /* 0b = The channel cannot accept all multicast addresses. 1b =
                                       supported. */
    uint32_t m_n_flow_ctrl_sup : 1; /* 0b = Management Controller to Network Controller flow control
                                      is not supported. 1b = supported. */
    uint32_t n_m_flow_ctrl_sup : 1; /* 0b = Network Controller to Management Controller flow control
                                      is not supported. 1b = supported. */
    uint32_t OS_presence_sup   : 1; /* 0b = OS Presence status is not supported. 1b = supported. */
    uint32_t hard_arbition_sup : 1; /* 0b = Hardware arbitration is not supported by the package. 1b
                                       = supported */
#else
    uint32_t hard_arbition_sup : 1;
    uint32_t OS_presence_sup   : 1;
    uint32_t n_m_flow_ctrl_sup : 1;
    uint32_t m_n_flow_ctrl_sup : 1;
    uint32_t multicast_sup     : 1;
    uint32_t reserved          : 27;
#endif
} capbility_define, *p_capbility_define;

typedef struct tg_channel_cap {
    capbility_define capbility_flag; // indicates which optional features of this specification the
                                     // channel supports
    // defines the optional broadcast packet filtering capabilities that the channel supports
    boradcast_filter broadcast_filter_capality;
    // defines the optional multicast packet filtering capabilities that he channel supports
    uint32_t multicast_filter_capality;
    // defines the amount of buffering in bytes that the channel provides for inbound packets,
    // destined for the Management Controller
    uint32_t buffer_capality;
    uint32_t aen_support;     // indicates various standard AENs supported by the implementation.
    uint8_t  vlan_filter_cnt; // indicates the number of VLAN filters
    uint8_t
        mix_filter_cnt; // indicates the number of mixed address filters that the channel supports.
    uint8_t mul_filter_cnt;     // indicates the number of multicast MAC address filters that the
                                // channel supports
    uint8_t unicast_filter_cnt; // indicates the number of unicast MAC address filters that the
                                // channel supports
    uint8_t reserved[2];
    uint8_t vlan_mode;   // indicates various modes supported by the implementation.
    uint8_t channel_cnt; // indicates the number of channels supported by the Network Controller
} channel_cap, *p_channel_cap;

typedef struct tg_pcie_device_ids {
    uint16_t pci_did;
    uint16_t pci_vid;
    uint16_t pci_ssid;
    uint16_t pci_svid;
} pcie_device_ids, *p_pcie_device_ids;

typedef struct {
#ifdef BD_BIG_ENDIAN
    uint32_t reserved3          : 8;
    uint32_t reserved2          : 2;
    uint32_t oem_link_speed     : 1;
    uint32_t serdes_link        : 1;
    uint32_t link_partner8      : 2;
    uint32_t rx_flow_control    : 1;
    uint32_t tx_flow_control    : 1;
    uint32_t link_partner7      : 1;
    uint32_t link_partner6      : 1;
    uint32_t link_partner5      : 1;
    uint32_t link_partner4      : 1;
    uint32_t link_partner3      : 1;
    guint32  link_partner2      : 1;
    uint32_t link_partner1      : 1;
    uint32_t channel_available  : 1;
    uint32_t parallel_detection : 1;
    uint32_t negotiate_complete : 1;
    uint32_t negotiate_flag     : 1;
    uint32_t speed_duplex       : 4;
    uint32_t link_flag          : 1;
#else
    uint32_t reserved3 : 8;

    uint32_t tx_flow_control    : 1;
    uint32_t rx_flow_control    : 1;
    uint32_t link_partner8      : 2;
    uint32_t serdes_link        : 1;
    uint32_t oem_link_speed     : 1;
    uint32_t reserved2          : 2; 
    uint32_t channel_available  : 1;
    uint32_t link_partner1      : 1;
    uint32_t link_partner2      : 1;
    uint32_t link_partner3      : 1;
    uint32_t link_partner4      : 1;
    uint32_t link_partner5      : 1;
    uint32_t link_partner6      : 1;
    uint32_t link_partner7      : 1; 
    uint32_t link_flag          : 1; 
    uint32_t speed_duplex       : 4; 
    uint32_t negotiate_flag     : 1;
    uint32_t negotiate_complete : 1;
    uint32_t parallel_detection : 1;
#endif
} ncsi_link_status;

typedef struct {
    uint16_t hw_netcard_enum;
#ifdef BD_BIG_ENDIAN
    uint32_t reserved2 : 8;

    uint32_t reserved        : 7;
    uint32_t need_configured : 1;
#else
    uint32_t reserved2 : 8;

    uint32_t need_configured : 1;
    uint32_t reserved        : 7;
#endif
} ncsi_oem_hw_link_status;

/*  Get Link Status Response (0x8A) */
#define GET_LINK_STATUS_RSP_LEN     16
#define GET_LINK_STATUS_RSP_PAD_LEN 10
typedef struct tg_get_link_status_rsp {
    uint16_t         rsp_code;
    uint16_t         reason_code;
    ncsi_link_status lnk_sts;
    uint32_t         other_indication;
    uint32_t         oem_link_status;
    uint32_t         check_sum;
    uint8_t          pad_data[GET_LINK_STATUS_RSP_PAD_LEN];
    uint32_t         FCS;
} link_status_rsp, *p_link_status_rsp;

#define NCSI_ETH_NAME_LEN  16  // IFNAMSIZ
#define NCSI_ETHER_MIN_LEN 290 // 46-1500 bytes:Data(NC-SI Control Packet)
/* 适配OCP 3.0,PackageID 协议支持 0-3,对应SLOT ID 0-3，但实际只有0-1，
   因此宏定义为2（定义成4的话，在NCSI故障的情况下导致BMC初始化时NCSI重试此时跑满，导致NCSI初始化时间过长）
 */
#define NCSI_PACKAGE_MAX_ID 2
#define NCSI_CHANNEL_MAX_ID 4
#define MAX_ETH_NUM         16
typedef struct tg_ncsi_parameter {
    uint8_t  uc_rcv_buf[NCSI_ETHER_MIN_LEN * 4 + NCSI_ETH_NAME_LEN];
    uint8_t  uc_send_buf[NCSI_ETHER_MIN_LEN * 4 + NCSI_ETH_NAME_LEN];
    uint8_t  ucIID;
    uint64_t ncsi_mutex;
    uint8_t  package[NCSI_PACKAGE_MAX_ID]; // 网络中存在的package，1表示存在，0表示不存在
    uint8_t  channel[NCSI_PACKAGE_MAX_ID]
                   [NCSI_CHANNEL_MAX_ID]; // 网络中存在的channel，1表示存在，0表示不存在
    uint8_t ncsi_ver[32];                 // 例如 Version 3.7.10a
    uint8_t firmware_ver[32];             // 例如 Version 00.03.02.17
    uint8_t firmware_name[16];
    uint8_t current_channel; // 当前正在使用的通道

    uint32_t manufacture_id; // 网卡当前的厂商id

    channel_cap      chn_cap[NCSI_PACKAGE_MAX_ID][NCSI_CHANNEL_MAX_ID];
    ncsi_link_status lnk_stauts[MAX_ETH_NUM][NCSI_CHANNEL_MAX_ID];
    uint32_t         oem_lnk_stauts[MAX_ETH_NUM][NCSI_CHANNEL_MAX_ID];
    pcie_device_ids  pci_ids;
    uint32_t         multicast_filter_cap;
    uint8_t          channel_cnt;
} ncsi_parameter, *p_ncsi_parameter;

typedef struct tg_common_packet {
    ethernet_header   frame_head;
    ctl_packet_header packet_head;
    uint8_t           payload[NCSI_ETHER_MIN_LEN * 4 - ETHER_HEADER_LEN - PACKET_HEADER_LEN];
    uint8_t           eth_name[NCSI_ETH_NAME_LEN];
} common_packet, *p_common_packet;

/* Get Controller Packet Statistics Command (0x18) */
#define GET_CONTROLLER_PACKET_STATISTICS_REQ_LEN     0
#define GET_CONTROLLER_PACKET_STATISTICS_RSP_LEN     204
#define GET_CONTROLLER_PACKET_STATISTICS_REQ_PAD_LEN 26
#define GET_CONTROLLER_PACKET_STATISTICS_RSP_PAD_LEN 0

typedef struct tg_controller_packet_statistics {
    uint32_t check_sum;
    uint8_t  pad_data[GET_CONTROLLER_PACKET_STATISTICS_REQ_PAD_LEN];
    uint32_t FCS;
} controller_packet_statistics, *p_controller_packet_statistics;

/* Get Controller Packet Statistics Response (0x98) */
typedef struct tg_controller_packet_statistics_rsp {
    uint16_t rsp_code;
    uint16_t reason_code;
    uint32_t counters_cleared_from_last_read_ms_bits;
    uint32_t counters_cleared_from_last_read_ls_bists;
    uint64_t total_bytes_received;
    uint64_t total_bytes_transmitted;
    uint64_t total_unicast_packets_received;
    uint64_t total_multicast_packets_received;
    uint64_t total_broadcast_packets_received;
    uint64_t total_unicast_packets_transmitted;
    uint64_t total_multicast_packets_transmitted;
    uint64_t total_broadcast_packets_transmitted;
    uint32_t fcs_received_errors;
    uint32_t alignment_errors;
    uint32_t false_carrier_detections;
    uint32_t runt_packets_received;
    uint32_t jabber_packets_received;
    uint32_t pause_xon_frames_received;
    uint32_t pause_xoff_frames_received;
    uint32_t pause_xon_frames_transmitted;
    uint32_t pause_xoff_frames_transmitted;
    uint32_t single_collision_transmit_frames;
    uint32_t multiple_collision_transmit_frames;
    uint32_t late_collision_frames;
    uint32_t excessive_collision_frames;
    uint32_t control_frames_received;
    uint32_t frames_64_octets_received;
    uint32_t frames_65_127_octets_received;
    uint32_t frames_128_255_octets_received;
    uint32_t frames_256_511_octets_received;
    uint32_t frames_512_1023_octets_received;
    uint32_t frames_1024_1522_octets_received;
    uint32_t frames_1523_9022_octets_received;
    uint32_t frames_64_octets_transmitted;
    uint32_t frames_65_127_octets_transmitted;
    uint32_t frames_128_255_octets_transmitted;
    uint32_t frames_256_511_octets_transmitted;
    uint32_t frames_512_1023_octets_transmitted;
    uint32_t frames_1024_1522_octets_transmitted;
    uint32_t frames_1523_9022_octets_transmitted;
    uint64_t valid_bytes_received;
    uint32_t error_runt_packets_received;
    uint32_t error_jabber_packets_received;
    uint32_t check_sum;
    uint32_t FCS;
} controller_packet_statistics_rsp, *p_controller_packet_statistics_rsp;

#pragma pack()

#ifdef __cplusplus
}
#endif

#endif // DEV_NCSI_SOCKET_H
